package com.gitee.huxing.course.controller;

import com.alibaba.fastjson.JSONObject;
import com.gitee.huxing.course.domain.dao.UserDAO;
import com.gitee.huxing.course.service.ICustomAutoService;
import com.gitee.huxing.klass.Klass;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description:
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.course.controller
 * @ClassName: TestController
 * @Author: huxing
 * @DateTime: 2021-09-05 下午1:48
 */
@RestController
public class TestController {

    @Resource(name = "userDao")
    UserDAO userDAO;

    @Resource(name = "userservice")
    UserDAO service;

    @Resource
    Klass klass;

    @Resource
    ICustomAutoService customAutoService;

    @RequestMapping("/api/v1/test")
    public String test(){
        // 快速批量插入
        this.service.task();
        return "批量处理成功";
//        // 打印自动装配结果
//        customAutoService.test();
//        // 查询结果记录集
//        StringBuilder builder = new StringBuilder();
//        builder.append("custom jdbc");
//        builder.append("<br/>");
//        builder.append(JSONObject.toJSONString(userDAO.list()));
//        builder.append("<br/>");
//        builder.append(JSONObject.toJSONString(userDAO.selectByName(
//                "ddf3c95daa874147b08c7e915002e3af")));
//        builder.append("<br/>");
//        // 查询结果记录集
//        builder.append("hikari jdbc");
//        builder.append("<br/>");
//        builder.append(JSONObject.toJSONString(service.list()));
//        builder.append("<br/>");
//        builder.append(JSONObject.toJSONString(service.selectByName(
//                "ddf3c95daa874147b08c7e915002e3af")));
//        return builder.toString();
    }

    /**
     * @Description: 查询学生记录信息
     * @Author: huxing
     * @return java.lang.String
     * @Date: 2021/9/5 下午2:17
     **/
    @RequestMapping("/api/v1/student/list")
    public String getStudents(){
        return JSONObject.toJSONString(klass.printStudents());
    }
}
